package com.wanshi.servlet;

import com.wanshi.entity.Product;
import com.wanshi.service.ProdService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/seller/prodInfoSeller")
public class prodInfoSeller extends HttpServlet {

    private ProdService prodService = new ProdService();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //获取商品id
        String id = request.getParameter("id");
        //2 根据id查询商品的详情
        Product product = prodService.findProdById(id);

        //3 存入request域
        request.setAttribute("prod", product);
        //4 转发到详情界面
        request.getRequestDispatcher("/seller/prodUpdate.jsp").forward(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}

